class Solution(object):

    def largeGroupPositions(self, S):
        """
        :type S: str
        :rtype: List[List[int]]
        """
        rlist = list()
        ch = bytes()
        count = 0
        for i in range(0, len(S)):
            if ch is S[i]:
                count = count + 1
            if ch != S[i]:
                if count >= 3:
                    rlist.append([i - count, i - 1])
                    count = 0
                ch = S[i]
                count = 1
            if len(S)-1 == i :
                if count >= 3:
                    rlist.append([i - count+1, i])
        return rlist

if __name__ == '__main__':
    s=Solution()
    s.largeGroupPositions("aaa")
